package com.merugu.school.mail;

import org.apache.commons.mail.*;

import javax.mail.*;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;
import java.security.Security;
import java.util.Properties;

/**
 * Created by IntelliJ IDEA.
 * User: raveendramerugu
 * Date: 12/20/10
 * Time: 11:44 AM
 * To change this template use File | Settings | File Templates.
 */
public class SmtpGmail {


    public static void sendMail() {
        try {
            HtmlEmail email = new HtmlEmail();
            email.setHostName("smtp.gmail.com");
            email.setSmtpPort(587);
            email.setAuthenticator(new DefaultAuthenticator("reddy.raveendra", "ravi1506"));
            email.setTLS(true);
            email.setFrom("reddy.raveendra@gmail.com");
            email.setSubject("TestMail");
        //    email.setHtmlMsg("<html>The apache logo - <img src=\"cid:" + 4444 + "\"></html>");
            email.addTo("reddy.raveendra@gmail.com");

            email.send();
        } catch (EmailException e) {
            e.printStackTrace();
        }

    }

    public static void main(String[] args) {
       sendMail();
    }

}
